package com.bm.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bm.common.dto.FriendsDto;
import com.bm.common.util.Rutils;
import com.bm.common.vo.R;
import com.bm.server.dao.FriendsDao;
import com.bm.server.dao.MyfriendDao;
import com.bm.server.entity.Friends;
import com.bm.server.entity.Myfriend;
import com.bm.server.service.intf.FriendsService;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.
 * |                     ______                     |
 * |                  .-"      "-.                  |
 * |                 /            \                 |
 * |     _          |              |          _     |
 * |    ( \         |,  .-.  .-.  ,|         / )    |
 * |     > "=._     | )(__/  \__)( |     _.=" <     |
 * |    (_/"=._"=._ |/     /\     \| _.="_.="\_)    |
 * |           "=._"(_     ^^     _)"_.="           |
 * |               "=\__|IIIIII|__/="               |
 * |              _.="| \IIIIII/ |"=._              |
 * |    _     _.="_.="\          /"=._"=._     _    |
 * |   ( \_.="_.="     `--------`     "=._"=._/ )   |
 * |    > _.="                            "=._ <    |
 * |   (_/                                    \_)   |
 * |                                                |
 * '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
 * -----------------代码的搬运工-----------------
 *
 * @Date: 2022/07/22/15:45
 */
@Service
public class FriendsServiceImpl implements FriendsService {
   @Resource
   private FriendsDao dao;
    @Override
    public R save(FriendsDto dto) {
        if(dto!=null){
            Friends friends = new Friends(dto.getUid(),dto.getInfo());
            if(dao.insert(friends)>0){
                return Rutils.ok("动态发布成功");
            }

        }
        return Rutils.fail("动态发布失败，请重新发布");
    }
    //查询所有动态
    @Override
    public R selectFriends() {
        return Rutils.ok(dao.selectAll1());
    }

    @Override
    public R updateId(int id) {
        if(id>0){
            if(dao.updateId(id)>0){
                return Rutils.ok("点赞成功！");
            }
        }
        return Rutils.fail();
    }
}
